import { ILogin } from "../common/defInterface";
import lyu from "../framework/lyu";

class GMongo {
    async getUserData(account: string): Promise<ILogin> {
        let accountData = await lyu.mongo().get({ account: account }, "user");
        if (accountData == null) {
            return null;
        }
        return accountData as any as ILogin;
    }

    async setUserData(userData: any) {
        await lyu.mongo().set(userData, "user");
    }

    async setLoginLog(loginData: any) {
        await lyu.mongo(1).set(loginData, "log");
    }
}

let gMongo = new GMongo();
export default gMongo;